<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" src="js/auswertung.js" type="text/javascript"> </script>
<script language="javascript" src="js/prototype.js" type="text/javascript"> </script>
<script language="javascript" src="js/deleteRun.js" type="text/javascript"> </script>
<script language="javascript" src="js/uebung.js" type="text/javascript"> </script>
<script language="javascript" src="js/endeUebung.js" type="text/javascript"> </script>

<link rel="stylesheet" href="css/aufbau.css" />
<title>Feuerwehr Zeitauswertung</title>
</head>


<body>
	<div id="nav">
    	<ul>
    		<li><a href="uebung.php">Übung</a></li>
            <li><a href="statistik.php">Statistik</a></li>
        </ul>
    </div>

    <div id="content"> 
		<?php 
				$db = @new mysqli('localhost', 'root', 'litec', 'zeitsteuerung');
	if (mysqli_connect_errno()) {
    	die ('Konnte keine Verbindung zur Datenbank aufbauen: ');
	}
	$sqlUebung = "SELECT * FROM t_uebung ORDER BY ueb_datum";
	$resUebung = $db->query($sqlUebung);
	echo "<form name=\"addUebung\" method=\"POST\" action=\"php/addUebung.php\">";
	echo "<h1>Neue Übung anlegen </h1>";
	echo "<table id=\"uebung\" border=\"1\">";
	echo "<tr><th>NR</th><th>Datum</th><th>Beginn</th></tr>";
	echo "<tr><td>";
	echo "<input type=\"text\" name=\"uebNr\"/>";
	echo "</td><td>";
	$date = getdate();
	echo "<input type=\"text\" name=\"uebDatum\" value=\"".$date['year']."-".$date['mon']."-".$date['mday']."\"/>";
	echo "</td><td>";
	echo "<input type=\"text\" name=\"uebBeginn\" value=\"".$date['hours'].":".$date['minutes']."\"/>";
	echo "</td><td>";
	//	<a href="javascript:addUebung()">Anlegen</a>
	?>
    <input type="submit" value="Anlegen"  />
	</form>
    <?php
	echo "</td></tr>";
	echo "</table>";
	echo "<h1>Übungen</h1>";
	echo "<div id=\"test\"></div>";
	echo "<table id=\"uebung\" border=\"1\">";
	echo "<tr><th>NR</th><th>Datum</th><th></th><th></th></tr>";
	while ($rowUebung = $resUebung->fetch_assoc()) {
		echo "<tr><td>";
		echo $rowUebung['ueb_nr'];
		echo "</td><td>";
		echo $rowUebung['ueb_datum'];
		echo "</td><td>";
		echo "<a href=\"lauf.php?ueb_id=".$rowUebung['ueb_id']."\" >Auswählen</a>";
		echo "</td><td><input type=\"button\" value=\"löschen\" onclick=\"deleteUebung(".$rowUebung['ueb_id'].")\" />";
		echo "</td></tr>";
	}
	echo "</table>";
	echo "</form>";
		
		
		?>
	</div>
</body>
</html>